<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

<script>
var formAuth;
var formRecherche;
var param = null;
function doOnLoad() {
	param = extractUrlParams();
	window.dhx_globalImgPath="../resources/images/";
	/**configuration du formulaire d'authentification**/
	formAuth = new dhtmlXForm("authentification");
	formAuth.loadStruct("../metier/XML/XMLAuthentification.php", function(){
		if(formAuth.isItem("donneesPerso")){
			formAuth.disableItem("donneesPerso");
		}
		if(formAuth.isItem("gestionUtilisateur")){
			formAuth.disableItem("gestionUtilisateur");
		}

	});
	formAuth.attachEvent("onButtonClick", function(name, command) {
		if (name == "seDeconnecter"){
			formAuth.send('../metier/seDeconnecter.php', function(loader) {
				reponse = loader.xmlDoc.responseText;
				alert(reponse);
				document.location.href="afficheAccueil.php";
			});
		}
		if (name == "seConnecter"){
			formAuth.send('../metier/seConnecter.php', function(loader) {
				reponse = loader.xmlDoc.responseText;
				if (reponse != null && reponse != ""){
					alert(reponse);
				} else {
					document.location.href="afficheAccueil.php";
				}
					
			});
		}
		if (name == "paramCentre"){
			document.location.href="afficheCentre.php";
		}
    });

	/**configuration du formulaire de recherche**/
	formRecherche = new dhtmlXForm("recherche");
	formRecherche.loadStruct("../metier/XML/XMLRecherche.php", function(){
			
			loadChampMarquePuce();
			formRecherche.getCombo("parMarque").attachEvent("onSelectionChange", function (id) {
				loadChampMarquePuce();
				formRecherche.getCombo("parModele").selectOption(0,true,true);
			});
		
			formRecherche.attachEvent("onButtonClick", function(name, command) {
				if (name == "choixPhenotype"){
					var dhxWins = new dhtmlXWindows();
					winPheno = dhxWins.createWindow("choixPheno", 10, 10, 1220, 1000);
					winPheno.setText("Choix de la clinique des patients à afficher dans la région");
					var formPheno = winPheno.attachForm();
					formPheno.loadStruct("../metier/XML/XMLFormPheno.php");
					formPheno.attachEvent("onChange", function(name){
						tab = name.split("_");
						if (tab[0] == "pheno"){
							if (formPheno.isItemChecked(name)){
								formPheno.setItemValue("requete", formPheno.getItemValue("requete")+";"+formPheno.getItemLabel(name));
							}
							else {
								spl = formPheno.getItemValue("requete").split(";"+formPheno.getItemLabel(name));
								if (spl[1]){
									formPheno.setItemValue("requete",spl[0]+spl[1]);
								}
								else {
									formPheno.setItemValue("requete",spl[0]);
								}
							}
						}
					});
					formPheno.attachEvent("onButtonClick", function(name, command) {
						if (name == "envoyer"){
							formRecherche.setItemValue("parPhenotype",formPheno.getCheckedValue("typeSeparateur")+formPheno.getItemValue("requete"));
						}						
							winPheno.close();
					});
					
				 }
				 
				 
				 if (name == "choixPhenotypePersonne"){
					var dhxWinsP = new dhtmlXWindows();
					winPhenoP = dhxWinsP.createWindow("choixPheno", 10, 10, 1220, 1000);
					winPhenoP.setText("Choix de la clinique des patients à rechercher");
					var formPhenoP = winPhenoP.attachForm();
					formPhenoP.loadStruct("../metier/XML/XMLFormPheno.php");
					formPhenoP.attachEvent("onChange", function(name){
						tab = name.split("_");
						if (tab[0] == "pheno"){
							if (formPhenoP.isItemChecked(name)){
								formPhenoP.setItemValue("requete", formPhenoP.getItemValue("requete")+";"+formPhenoP.getItemLabel(name));
							}
							else {
								spl = formPhenoP.getItemValue("requete").split(";"+formPhenoP.getItemLabel(name));
								if (spl[1]){
									formPhenoP.setItemValue("requete",spl[0]+spl[1]);
								}
								else {
									formPhenoP.setItemValue("requete",spl[0]);
								}
							}
						}
					});
					formPhenoP.attachEvent("onButtonClick", function(name, command) {
						if (name == "envoyer"){
							formRecherche.setItemValue("parPhenotypePersonne",formPhenoP.getCheckedValue("typeSeparateur")+formPhenoP.getItemValue("requete"));
						}						
							winPhenoP.close();
					});
					
				 }
				 
				 
			});
			
	});
				
	formRecherche.attachEvent("onButtonClick", function(name, command) {
		if (name == "rechercher"){
			if(formRecherche.validate()){
	            document.forms["formRecherche"].submit();
			}
		}
    });

	/**configuration du formulaire ACPA**/
	formGestion = new dhtmlXForm("gestionAcpa");
	formGestion.loadStruct("../metier/XML/XMLGestionACPA.php", function(){
		if(formGestion.isItem("listePatient")){
			formGestion.disableItem("listePatient");
		}
		if(formGestion.isItem("export")){
			formGestion.disableItem("export");
		}
		if(formGestion.isItem("rapportACPA")){
			formGestion.disableItem("rapportACPA");
		}
		if(formGestion.isItem("rapportBiomed")){
			formGestion.disableItem("rapportBiomed");
		}
	});
	formGestion.attachEvent("onButtonClick", function(name, command) {
		if (name == "creerDossier"){
	            document.location.href="afficheDossier.php?idDossier=0";
		}
		if (name == "import"){
	            document.location.href="afficheImport.php";
		}
    });

}
function loadChampMarquePuce() {
    var typePuce;
    var typeLogiciel;
    if (typeof (formRecherche.getCombo("parModele")) == 'undefined' || typeof (formRecherche.getCombo("parModele").getComboText()) == 'undefined') {
        typePuce = 0;
    } else {
        typePuce = formRecherche.getCombo("parModele").getComboText();
    }
    formRecherche.getCombo("parModele").loadXML( "../metier/XML/XMLComboTypePuce.php?idMarquePuce=" + formRecherche.getCombo("parMarque").getSelectedValue(),
            function() {
                formRecherche.getCombo("parModele").selectOption(typePuce,
                        true, true);
            });
    
    
}
</script>
<table>
	<tr>
		<td>
			<div id="authentification"></div>
		</td>
		<td colspan ="3">
			<div id="presentation" class="panel">
			<H1>Présentation</H1>
			Cette base de donnée à pour objectif de répertorier les variation en
			nombre de copie (CNV) des analyses sur puces à ADN consitutielles
			réalisées sur le réseau AchroPuce.
			</div>
		</td>
	</tr>
	<tr>
		{if isset($id) && !is_null($id) && $id != 0}
			<td colspan="2" >
		{else}
			<td colspan="4" >
		{/if}
			<form action="../metier/rechercher.php" method="post" id="formRecherche">
    			<div id="recherche" class="panel">
					<H1>Rechercher</H1>
				</div>
			</form>
			
		</td>
		{if isset($id) && !is_null($id) && $id != 0}
			<td colspan="2">
					<div id="gestionAcpa" class="panel">
						<H1>Gestion des analyses de votre centre</H1>
					</div>

			</td>
			<tr/>
		{/if}
	</tr>

</table>